/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  
  checkConfig(config);
  @endpoint = getEndpoint('alikafka', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CreateConsumerGroupRequest {
  consumerId?: string(name='ConsumerId', description='This parameter is required.', example='consumer_group_test'),
  instanceId?: string(name='InstanceId', description='This parameter is required.', example='alikafka_pre-cn-0pp1954n****'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
}

model CreateConsumerGroupResponseBody = {
  code?: int32(name='Code', example='200'),
  message?: string(name='Message', example='operation success'),
  requestId?: string(name='RequestId', example='B191CC4D-B067-4508-987A-ACDA8D89****'),
  success?: boolean(name='Success', example='true'),
}

model CreateConsumerGroupResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateConsumerGroupResponseBody(name='body'),
}

/**
 * @summary 创建 Group
 *
 * @param request CreateConsumerGroupRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateConsumerGroupResponse
 */
async function createConsumerGroupWithOptions(request: CreateConsumerGroupRequest, runtime: Util.RuntimeOptions): CreateConsumerGroupResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.consumerId)) {
    query['ConsumerId'] = request.consumerId;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateConsumerGroup',
    version = '2018-10-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 创建 Group
 *
 * @param request CreateConsumerGroupRequest
 * @return CreateConsumerGroupResponse
 */
async function createConsumerGroup(request: CreateConsumerGroupRequest): CreateConsumerGroupResponse {
  var runtime = new Util.RuntimeOptions{};
  return createConsumerGroupWithOptions(request, runtime);
}

model CreateTopicRequest {
  instanceId?: string(name='InstanceId', description='This parameter is required.', example='alikafka_pre-cn-mp919o4v****'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
  remark?: string(name='Remark', description='This parameter is required.', example='alikafka_topic_test'),
  topic?: string(name='Topic', description='This parameter is required.', example='alikafka_topic_test'),
}

model CreateTopicResponseBody = {
  code?: int32(name='Code', example='200'),
  message?: string(name='Message', example='operation success'),
  requestId?: string(name='RequestId', example='9C0F207C-77A6-43E5-991C-9D98510A****'),
  success?: boolean(name='Success', example='true'),
}

model CreateTopicResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateTopicResponseBody(name='body'),
}

/**
 * @param request CreateTopicRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateTopicResponse
 */
async function createTopicWithOptions(request: CreateTopicRequest, runtime: Util.RuntimeOptions): CreateTopicResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.remark)) {
    query['Remark'] = request.remark;
  }
  if (!Util.isUnset(request.topic)) {
    query['Topic'] = request.topic;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateTopic',
    version = '2018-10-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request CreateTopicRequest
 * @return CreateTopicResponse
 */
async function createTopic(request: CreateTopicRequest): CreateTopicResponse {
  var runtime = new Util.RuntimeOptions{};
  return createTopicWithOptions(request, runtime);
}

model DeleteConsumerGroupRequest {
  consumerId?: string(name='ConsumerId', description='This parameter is required.', example='testconsumer'),
  instanceId?: string(name='InstanceId', description='This parameter is required.', example='alikafka_post-cn-mp91a44k****'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
}

model DeleteConsumerGroupResponseBody = {
  code?: int32(name='Code', example='200'),
  message?: string(name='Message', example='operation success'),
  requestId?: string(name='RequestId', example='1AA2A2AD-2727-4573-B1C7-A0388BCD****'),
  success?: boolean(name='Success', example='true'),
}

model DeleteConsumerGroupResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteConsumerGroupResponseBody(name='body'),
}

/**
 * @param request DeleteConsumerGroupRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteConsumerGroupResponse
 */
async function deleteConsumerGroupWithOptions(request: DeleteConsumerGroupRequest, runtime: Util.RuntimeOptions): DeleteConsumerGroupResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.consumerId)) {
    query['ConsumerId'] = request.consumerId;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteConsumerGroup',
    version = '2018-10-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request DeleteConsumerGroupRequest
 * @return DeleteConsumerGroupResponse
 */
async function deleteConsumerGroup(request: DeleteConsumerGroupRequest): DeleteConsumerGroupResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteConsumerGroupWithOptions(request, runtime);
}

model DeleteTopicRequest {
  instanceId?: string(name='InstanceId', description='This parameter is required.', example='alikafka_post-cn-mp91a44k****'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
  topic?: string(name='Topic', description='This parameter is required.', example='Kafkatest'),
}

model DeleteTopicResponseBody = {
  code?: int32(name='Code', example='200'),
  message?: string(name='Message', example='operation success'),
  requestId?: string(name='RequestId', example='9B618B3F-9506-4661-A211-D00C4556****'),
  success?: boolean(name='Success', example='true'),
}

model DeleteTopicResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteTopicResponseBody(name='body'),
}

/**
 * @param request DeleteTopicRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteTopicResponse
 */
async function deleteTopicWithOptions(request: DeleteTopicRequest, runtime: Util.RuntimeOptions): DeleteTopicResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.topic)) {
    query['Topic'] = request.topic;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteTopic',
    version = '2018-10-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request DeleteTopicRequest
 * @return DeleteTopicResponse
 */
async function deleteTopic(request: DeleteTopicRequest): DeleteTopicResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteTopicWithOptions(request, runtime);
}

model GetConsumerListRequest {
  instanceId?: string(name='InstanceId', description='This parameter is required.', example='alikafka_post-cn-v0h18sav****'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
}

model GetConsumerListResponseBody = {
  code?: int32(name='Code', example='200'),
  consumerList?: {
    consumerVO?: [ 
    {
      consumerId?: string(name='ConsumerId', example='CID_c34a6f44915f80d70cb42c4b14ee40c3_4'),
      instanceId?: string(name='InstanceId', example='alikafka_post-cn-v0h18sav0001'),
      regionId?: string(name='RegionId', example='cn-hangzhou'),
    }
  ](name='ConsumerVO')
  }(name='ConsumerList'),
  message?: string(name='Message', example='operation success.'),
  requestId?: string(name='RequestId', example='808F042B-CB9A-4FBC-9009-00E7DDB6****'),
  success?: boolean(name='Success', example='true'),
}

model GetConsumerListResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetConsumerListResponseBody(name='body'),
}

/**
 * @param request GetConsumerListRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetConsumerListResponse
 */
async function getConsumerListWithOptions(request: GetConsumerListRequest, runtime: Util.RuntimeOptions): GetConsumerListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetConsumerList',
    version = '2018-10-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GetConsumerListRequest
 * @return GetConsumerListResponse
 */
async function getConsumerList(request: GetConsumerListRequest): GetConsumerListResponse {
  var runtime = new Util.RuntimeOptions{};
  return getConsumerListWithOptions(request, runtime);
}

model GetConsumerProgressRequest {
  consumerId?: string(name='ConsumerId', description='Consumer Group ID。

This parameter is required.', example='kafka-test'),
  instanceId?: string(name='InstanceId', description='This parameter is required.', example='alikafka_pre-cn-mp919o4v****'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
}

model GetConsumerProgressResponseBody = {
  code?: int32(name='Code', example='200'),
  consumerProgress?: {
    lastTimestamp?: long(name='LastTimestamp', example='1566874931671'),
    topicList?: {
      topicList?: [ 
      {
        lastTimestamp?: long(name='LastTimestamp', example='1566874931649'),
        offsetList?: {
          offsetList?: [ 
          {
            brokerOffset?: long(name='BrokerOffset', example='9'),
            consumerOffset?: long(name='ConsumerOffset', example='9'),
            lastTimestamp?: long(name='LastTimestamp', example='1566874931649'),
            partition?: int32(name='Partition', example='0'),
          }
        ](name='OffsetList')
        }(name='OffsetList'),
        topic?: string(name='Topic', example='kafka-test'),
        totalDiff?: long(name='TotalDiff', example='0'),
      }
    ](name='TopicList')
    }(name='TopicList'),
    totalDiff?: long(name='TotalDiff', example='0'),
    state?: string(name='state'),
  }(name='ConsumerProgress'),
  message?: string(name='Message', example='operation success.'),
  requestId?: string(name='RequestId', example='252820E1-A2E6-45F2-B4C9-1056B8CE****'),
  success?: boolean(name='Success', example='true'),
}

model GetConsumerProgressResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetConsumerProgressResponseBody(name='body'),
}

/**
 * @param request GetConsumerProgressRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetConsumerProgressResponse
 */
async function getConsumerProgressWithOptions(request: GetConsumerProgressRequest, runtime: Util.RuntimeOptions): GetConsumerProgressResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.consumerId)) {
    query['ConsumerId'] = request.consumerId;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetConsumerProgress',
    version = '2018-10-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GetConsumerProgressRequest
 * @return GetConsumerProgressResponse
 */
async function getConsumerProgress(request: GetConsumerProgressRequest): GetConsumerProgressResponse {
  var runtime = new Util.RuntimeOptions{};
  return getConsumerProgressWithOptions(request, runtime);
}

model GetInstanceListRequest {
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
}

model GetInstanceListResponseBody = {
  code?: int32(name='Code', example='200'),
  instanceList?: {
    instanceVO?: [ 
    {
      createTime?: long(name='CreateTime', example='1566215995000'),
      deployType?: int32(name='DeployType', example='4'),
      endPoint?: string(name='EndPoint', example='192.168.0.212:9092,192.168.0.210:9092,192.168.0.211:****'),
      expiredTime?: long(name='ExpiredTime', example='1568908800000'),
      instanceId?: string(name='InstanceId', example='alikafka_pre-cn-mp919o4v****'),
      name?: string(name='Name', example='alikafka_pre-cn-mp919o4v****'),
      regionId?: string(name='RegionId', example='cn-hangzhou'),
      serviceStatus?: int32(name='ServiceStatus', example='5'),
      sslEndPoint?: string(name='SslEndPoint', example='47.111.110.11:9093,121.40.96.141:9093,47.111.118.133:****'),
      upgradeServiceDetailInfo?: {
        upgradeServiceDetailInfoVO?: [ 
        {
          current2OpenSourceVersion?: string(name='Current2OpenSourceVersion', example='0.10'),
        }
      ](name='UpgradeServiceDetailInfoVO')
      }(name='UpgradeServiceDetailInfo'),
      vSwitchId?: string(name='VSwitchId', description='VSwitch ID。', example='vsw-bp13rg6bcpkxofr78****'),
      vpcId?: string(name='VpcId', description='VPC ID。', example='vpc-bp1l6hrlykj3405r7****'),
    }
  ](name='InstanceVO')
  }(name='InstanceList'),
  message?: string(name='Message', example='operation success.'),
  requestId?: string(name='RequestId', example='ABA4A7FD-E10F-45C7-9774-A5236015****'),
  success?: boolean(name='Success', example='true'),
}

model GetInstanceListResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetInstanceListResponseBody(name='body'),
}

/**
 * @param request GetInstanceListRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetInstanceListResponse
 */
async function getInstanceListWithOptions(request: GetInstanceListRequest, runtime: Util.RuntimeOptions): GetInstanceListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetInstanceList',
    version = '2018-10-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GetInstanceListRequest
 * @return GetInstanceListResponse
 */
async function getInstanceList(request: GetInstanceListRequest): GetInstanceListResponse {
  var runtime = new Util.RuntimeOptions{};
  return getInstanceListWithOptions(request, runtime);
}

model GetTopicListRequest {
  currentPage?: string(name='CurrentPage'),
  instanceId?: string(name='InstanceId', description='This parameter is required.', example='alikafka_pre-cn-0pp1954n2003'),
  pageSize?: string(name='PageSize'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
}

model GetTopicListResponseBody = {
  code?: int32(name='Code', example='200'),
  currentPage?: int32(name='CurrentPage', example='1'),
  message?: string(name='Message', example='operation success.'),
  pageSize?: int32(name='PageSize', example='10000'),
  requestId?: string(name='RequestId', example='82BD585C-17A1-486E-B3E8-AABCE8EE****'),
  success?: boolean(name='Success', example='true'),
  topicList?: {
    topicVO?: [ 
    {
      createTime?: long(name='CreateTime', example='1566804394000'),
      instanceId?: string(name='InstanceId', example='alikafka_pre-cn-0pp1954n****'),
      regionId?: string(name='RegionId', example='cn-hangzhou'),
      remark?: string(name='Remark', example='kafka_test_topic'),
      status?: int32(name='Status', example='0'),
      statusName?: string(name='StatusName'),
      topic?: string(name='Topic', example='poptest'),
    }
  ](name='TopicVO')
  }(name='TopicList'),
  total?: int32(name='Total', example='12'),
}

model GetTopicListResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetTopicListResponseBody(name='body'),
}

/**
 * @param request GetTopicListRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetTopicListResponse
 */
async function getTopicListWithOptions(request: GetTopicListRequest, runtime: Util.RuntimeOptions): GetTopicListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.currentPage)) {
    query['CurrentPage'] = request.currentPage;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetTopicList',
    version = '2018-10-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GetTopicListRequest
 * @return GetTopicListResponse
 */
async function getTopicList(request: GetTopicListRequest): GetTopicListResponse {
  var runtime = new Util.RuntimeOptions{};
  return getTopicListWithOptions(request, runtime);
}

model GetTopicStatusRequest {
  instanceId?: string(name='InstanceId', description='This parameter is required.', example='alikafka_pre-cn-v0h15tjmo003'),
  regionId?: string(name='RegionId'),
  topic?: string(name='Topic', description='This parameter is required.', example='normal_topic_9d034262835916103455551be06cc2dc_6'),
}

model GetTopicStatusResponseBody = {
  code?: int32(name='Code', example='200'),
  message?: string(name='Message', example='operation success.'),
  requestId?: string(name='RequestId', example='E475C7E2-8C35-46EF-BE7D-5D2A9F5D****'),
  success?: boolean(name='Success', example='true'),
  topicStatus?: {
    lastTimeStamp?: long(name='LastTimeStamp', example='1566470063575'),
    offsetTable?: {
      offsetTable?: [ 
      {
        lastUpdateTimestamp?: long(name='LastUpdateTimestamp', example='1566470063547'),
        maxOffset?: long(name='MaxOffset', example='76'),
        minOffset?: long(name='MinOffset', example='0'),
        partition?: int32(name='Partition', example='0'),
        topic?: string(name='Topic', example='testkafka'),
      }
    ](name='OffsetTable')
    }(name='OffsetTable'),
    totalCount?: long(name='TotalCount', example='423'),
  }(name='TopicStatus'),
}

model GetTopicStatusResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetTopicStatusResponseBody(name='body'),
}

/**
 * @param request GetTopicStatusRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetTopicStatusResponse
 */
async function getTopicStatusWithOptions(request: GetTopicStatusRequest, runtime: Util.RuntimeOptions): GetTopicStatusResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.topic)) {
    query['Topic'] = request.topic;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetTopicStatus',
    version = '2018-10-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GetTopicStatusRequest
 * @return GetTopicStatusResponse
 */
async function getTopicStatus(request: GetTopicStatusRequest): GetTopicStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  return getTopicStatusWithOptions(request, runtime);
}

